//获取当天当地天气
var city = new Array("安徽","黑龙江","山东","北京","湖北","山西","福建","湖南","陕西","甘肃","吉林","上海","广东","江苏","四川","广西","江西","天津","贵州","辽宁","西藏","海南","内蒙古","新疆","河北","宁夏","云南","河南","青海","浙江","重庆");  
var weaths = new Array('58321','50953','54823','54511','57494','53772','59134','57679','57036','52889','54172','58367','59287','58238','56294','59431','58606','54527','57816','54342','55591','52856','53463','51463','53698','53614','56778','57083','52866','58457','57516');  
  
function getCookieVal (offset) {  
  var endstr = document.cookie.indexOf (";", offset);  
  if (endstr == -1)  
  endstr = document.cookie.length;  
  return unescape(document.cookie.substring(offset, endstr));  
}  
function GetCookie (name) {  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  
  while (i < clen) {  
    var j = i + alen;  
    if (document.cookie.substring(i, j) == arg)  
      return getCookieVal (j);  
    i = document.cookie.indexOf(" ", i) + 1;  
    if (i == 0)  
       break;  
  }  
  return "";  
}  
function SetCookie(cookieName,cookieValue,nDays) {  
 var today = new Date();  
 var expire = new Date();  
 if (nDays==null || nDays==0) nDays=1;  
 expire.setTime(today.getTime() + 3600000*24*nDays);  
 document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;domain=.163.com;expires="+expire.toGMTString();  
}  
function getCityWeatherID(cityname){  
    for(i=0;i<city.length;i++){  
    if(city[i]==cityname){  
        return weaths[i];  
        }  
    }  
    return "54511";  
}  
  
var NTES_WeatherAddr = GetCookie("NTES_WeatherAddr");  
if (!NTES_WeatherAddr){  
    var loc = GetCookie("theaddr");  
    if(!loc){  
        document.write("<script type='text/javascript' src='http://202.108.39.152/ipquery'><" + "/script>");  
    }  
}  
 
if (!NTES_WeatherAddr){  
    NTES_WeatherAddr=getCityWeatherID(loc);  
}  
function getWeather(){
	createXMLHttpRequest();
	var queryString = "inc/bw.asp?wa="+NTES_WeatherAddr+"&timestamp="+ new Date().getTime();
	xmlHttp.onreadystatechange = handlegetweatherStateChange;
	xmlHttp.open("GET",queryString, true);
	xmlHttp.send(null);
}
setTimeout("getWeather();",499);

function handlegetweatherStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            var ajaxRequestObj = xmlHttp.responseText;
			var top = document.getElementById("index_title_top");
			top.innerHTML=top.innerHTML+ajaxRequestObj;
		}
    }
}